
import CountUI from '../../component/Count'
import { createIncreatementAction, createDecreatementAction, createIncreatmentAsyncAction } from '../../redux/countAction'

// 引入connect连接UI组件和redux
import { connect } from 'react-redux'

export default connect( 
    state =>  ({ count: state }),
    // 一般写法
    /*dispatch => (
        {
            jia: value => { dispatch( createIncreatementAction( value ) ) },
            jian: value => { dispatch( createDecreatementAction( value ) ) },
            jiaAsync: ( value, time ) => { dispatch( createIncreatmentAsyncAction( value, time ) ) }
        } 
    )*/

    /* 简化版写法
        mapDispatchToProps也可以是一个对象，对象的value值直接是一个action方法，action方法一定定义好且已经可以接受参数
    */
    {
        jia: createIncreatementAction,
        jian: createDecreatementAction,
        jiaAsync: createIncreatmentAsyncAction
    }


    )( CountUI )